﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;

namespace Whoever.Website.Framework.Utilities
{
    public class EmailSender
    {
        public void Send(Email email)
        {
            var mailMessage = new MailMessage(email.SenderAddress,email.ReceiverAddress,email.Subject,email.Body);
            var smtpClient = new SmtpClient(email.SmtpServer);
            mailMessage.IsBodyHtml = email.IsHtmlBody;
            smtpClient.Host = email.SmtpServer;
            smtpClient.Port = 25;
            smtpClient.EnableSsl = false;
            smtpClient.UseDefaultCredentials = false;
            smtpClient.Credentials = new System.Net.NetworkCredential(email.SenderAddress, email.SenderPassword);

            try
            {
                smtpClient.Send(mailMessage);
            }
            catch(Exception ex)
            {
                throw ex;
            }

        }
    }
}
